package com.ww.springboot.boot.thread.study.base.interrupt;

import java.util.concurrent.TimeUnit;

/**
 * interrupted 会立刻重置中断标识
 *
 * @author wanwei
 * @since 2021-04-17 15:46
 */
public class InterruptDemo5 {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread() {
            @Override
            public void run() {
                while (true) {
                    System.out.println(Thread.interrupted());
                }
            }
        };
        thread.setDaemon(true);
        thread.start();
        //shortly block make sure the thread is started.
        TimeUnit.MILLISECONDS.sleep(2);
        thread.interrupt();
    }
}
